package com.gadgets.framework.thread.basic;

import java.io.Serializable;

/**
 * @author UncleXiu
 * @version V1.0.0
 * @data 2020-09-12
 *
 */
public class ThreadPoolConfiguration implements Serializable {
    /**
     * 模块编号
     */
    private String moduelNo;
    /**
     * 最小线程数
     */
    private Integer minThread;
    /**
     * 最大线程数
     */
    private Integer maxThread;
    /**
     * 当前线程数
     */
    private Integer currentThread;
    /**
     * 限流队列大小
     */
    private Integer flowLimitSize;
    /**
     * 线程升级阈值
     */
    private Double levelUpThreshold;
    /**
     * 线程降级阈值
     */
    private Double levelDownThreshold;

    public String getModuelNo() {
        return moduelNo;
    }

    public void setModuelNo(String moduelNo) {
        this.moduelNo = moduelNo;
    }

    public Integer getMinThread() {
        return minThread;
    }

    public void setMinThread(Integer minThread) {
        this.minThread = minThread;
    }

    public Integer getMaxThread() {
        return maxThread;
    }

    public void setMaxThread(Integer maxThread) {
        this.maxThread = maxThread;
    }

    public Integer getFlowLimitSize() {
        return flowLimitSize;
    }

    public void setFlowLimitSize(Integer flowLimitSize) {
        this.flowLimitSize = flowLimitSize;
    }

    public Double getLevelUpThreshold() {
        return levelUpThreshold;
    }

    public void setLevelUpThreshold(Double levelUpThreshold) {
        this.levelUpThreshold = levelUpThreshold;
    }

    public Double getLevelDownThreshold() {
        return levelDownThreshold;
    }

    public void setLevelDownThreshold(Double levelDownThreshold) {
        this.levelDownThreshold = levelDownThreshold;
    }

    public Integer getCurrentThread() {
        return currentThread;
    }

    public void setCurrentThread(Integer currentThread) {
        this.currentThread = currentThread;
    }

    public int getLevelUpNum(){
        return (int) (flowLimitSize * levelUpThreshold);
    }

    public int getLevelDownNum(){
        return (int) (flowLimitSize * levelDownThreshold);
    }

    public void levelUp(){
        currentThread++;
    }

    public void levelDown(){
        currentThread--;
    }

}
